package org.mark.hibernate;

import org.hibernate.Session;
import org.hibernate.SessionFactory;

import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

public class Main {
	public static void main(String[] args) {

		ApplicationContext context = new ClassPathXmlApplicationContext("beansConfig.xml");
		IBookModel book = (IBookModel)context.getBean("TestBook");
		
		SessionFactory sf = HibernateUtil.getSessionFactory();
		Session session = sf.openSession();

		session.beginTransaction(); 

		session.save(book);		
		session.getTransaction().commit();
		
		session.close();
	}
}
